Shutdown Handling

RTX Shutdown handling prepares real-time devices that are controlled by RTX for a sudden Windows death caused either by a Windows emergency Blue screen crash or by “normal” Windows shutdown initiated outside of RTSS. When it happens, RTX postpones Windows imminent death and switches to RTX Shutdown mode which allows RTSS applications to make emergency clean-up calls. During RTX Shutdown handling, the RTSS subsystem is still operational and fully functional; Win32 RTX threads are not. Only RTSS processes with handlers attached by an RtAttachShutdownhandler call will function during RTX Shutdown. We will name such processes the shutdown processes. There is no time restriction on RTX Shutdown duration, it can even be forever (but Windows will never perform its own shutdown then).

Shutdown processes behave differently than other processes in RTX Shutdown mode. Only these RTSS processes remain functional during Windows shutdown while all others are frozen. Every shutdown handler, attached by RtAttachShutdownhandler, performs in separate RTSS threads context, and will be active during RTX Shutdown only. During normal Windows and RTX operations, these RTSS shutdown threads are dormant. Only one shutdown handler can be attached to RTSS process. The second RtAttachShutdownhandler call for the same process will be ignored, unless there was RtReleaseShutdownhandler call.

The shutdown thread starts by calling the shutdown handler attached by RtAttachShutdownhandler This handler has two arguments, first one defined by user in the RtAttachShutdownhandler call, and the second one provided by RTX to describe the reason for the current shutdown. The second argument helps the shutdown handler dynamically detect what is wrong with Windows.

The shutdown thread is not the only active RTSS shutdown processes thread during Windows shutdown. All other RTSS shutdown processes threads are also active and not restricted from usual RTSS real-time performance (where Windows help is not needed). However, depending on the type of Windows shutdown, they can be restricted from all or some non-real-time calls. Windows will be able to continue its shutdown only after all RTSS shutdown processes have finished. As soon as the last RTSS shutdown process exits, RTSS is stopped or unloaded and Windows continues the shutdown process.

During RTX shutdown, the RTSS shutdown process can manipulate all threads with its shutdown thread — it can postpone or even change its priority (this is not wise), but it cannot create new RTSS threads and objects. To obtain the shutdown thread handle, it can call GetCurrentThread in the shutdown thread context. The only difference is, that if the shutdown thread exits or is terminated (because of “return”, ExitThread or TerminateThread calls) – the whole shutdown process also exits (exactly the same effect as it was the main thread).

NOTE:  If a call to KeBugCheck or KeBugCheckEx occurs at high IRQL, and a shutdown handler has RtPrintf or printf calls, a shutdown handler may become stuck at the point of print call. This is because the Windows core(s) are not able to service the print request from RTSS due to being at high IRQL.

IMPORTANT!  When using certain video cards, shutdown handlers can malfunction or hang if the Windows display is not in VGA mode prior to the Windows shutdown event (i.e., a Windows crash or normal Windows shutdown). Even when the display is in VGA mode, shutdown handlers should refrain from excessive calls to RtPrintf, because this can prevent Windows from generating a crash dump and rebooting.

Windows Blue Screen Shutdown

All shutdown process threads are active, plus there is one extra-thread, the shutdown thread. RTX Timer works, and all threads can perform real-time calls. However, they cannot call any non real-time functions, involved Windows services, because only RTSS subsystem is able to work while Windows is fatally damaged and going to die. The only exceptions are RtPrintf and printf calls, which in RTX Shutdown mode will print directly on Blue Screen, but the volume of the print-outs is restricted by the Blue Screen size.

Windows Normal Shutdown

All shutdown process threads are alive, plus there is one extra thread, the shutdown thread. RTX Timer works, and all threads can perform almost any call, not just real-time calls. In particular, printf and RtPrintf will not have any effect, because the Windows GUI does not respond at this stage. At this stage, it is not recommended that you create new RTSS threads and objects, because Windows has already shut down several services.

 

See Also

IntervalZero.com | Support | Give Feedback